package net.ddns.xcyyds.kungfu.procedures;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.network.chat.TextComponent;

import net.ddns.xcyyds.kungfu.network.KungFuModVariables;

public class OneHandJianProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		if ((entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null)
				.orElse(new KungFuModVariables.PlayerVariables())).oneHandJian >= 0
				&& (entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null)
						.orElse(new KungFuModVariables.PlayerVariables())).oneHandJian < KungFuModVariables.MapVariables.get(world).sld1) {
			if ((entity.getPersistentData().getString("NO3")).equals("R") || (entity.getPersistentData().getString("NO3")).equals("L")) {
				if (entity instanceof Player _player && !_player.level.isClientSide())
					_player.displayClientMessage(
							new TextComponent(
									"\u00A7c\u4F60\u7684\u719F\u7EC3\u5EA6\u4E0D\u591F\u91CA\u653E\u8BE5\u7EA7\u522B\u7684\u62DB\u5F0F\uFF01"),
							(true));
			} else {
				OneHandJian2Procedure.execute(world, x, y, z, entity);
			}
		}
	}
}
